/*
* Author	: sgxiao
* Date		: Mon Dec 15 23:21:26 CST 2008
* version	: 0.3
* history
*	sgxiao	0.3	modified fit for group
*	sgxiao	0.2	add a arguments to check the count of top n
*	sgxiao	0.1	build up
*/
import java.util.*;
import java.io.*;

public class MarketCapTop50  {
	public static void main(String[] args) throws IOException {
		//int SMA[] = { 1, 2, 5, 10, 50, 150, 200};
		
		List<Stock> stocks = new ArrayList<Stock>();
		Scanner scanner = new Scanner(new File(args[0]));
		
		Iterator<Stock> iterator;
		while(scanner.hasNext()) {
			
			Stock stock = new Stock();
			stock.setTicker(scanner.next());
			stock.setTotal(scanner.nextDouble());
			stocks.add(stock);
		}
	
		//sort
		Collections.sort(stocks);
		//System.out.println("Top " + 50 + ":");
		iterator = stocks.iterator();
		int count = 0;
		//double SMA_total = 0.0;
		
		int top = Integer.valueOf(args[1]);
		while( count++ < top) {
			Stock temp = (Stock)iterator.next();
			
			//System.out.printf("%s\t%f\n", temp.getTicker(), temp.getTotal());
			System.out.printf("%s\n", temp.getTicker());
			//SMA_total += temp.getTotal();
		}
		//System.out.println(SMA_total + "\t" + SMA[i]);
		
		//System.out.printf("\ntotal:\t%f\n\n", SMA_total / SMA[i]);
		//System.out.println("\n\n\n-------------------");
		
	}
}